<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Staff extends Model
{
    protected $fillable = [
        'user_id', 'company_id', 'dept_id', 'name', 'mobile', 'role_status',
    ];
    protected function getDateFormat()
    {
        return time();
    }
    public static $rules = [
        'type' => 'required|in:1,2',
        'deptId' => 'required',
        'name' => 'required|max:20',
        'mobile' => 'required|regex:/^[1][0-9]{10}$/',
        'email' => 'sometimes|nullable|email',
        'position' => 'sometimes|max:255',
        'employeeNo' => 'sometimes|max:255',
        'entryTime' => 'sometimes|nullable|integer:10',
        'remarks' => 'sometimes|max:255',
    ];
    public static $rules_edit = [
        'type' => 'required|in:1,2',
        'deptId' => 'required',
        'name' => 'required|max:20',
        'email' => 'sometimes|nullable|email',
        'position' => 'sometimes|max:255',
        'employeeNo' => 'sometimes|max:255',
        'entryTime' => 'sometimes|nullable|integer:10',
        'remarks' => 'sometimes|max:255',
    ];
    public static $message = [
        'type.required'=>'类型不能为空',
        'type.in'=>'类型参数不正确或无效',
        'deptId.required'=>'部门ID不能为空',
        'name.required' => '姓名必须填写',
        'name.max' => '姓名最多20个字符',
        'mobile.required' => '手机号不能为空',
        'mobile.regex' => '手机号格式不正确',
        'email.email' => '邮箱格式不正确',
        'position.max' => '职位最多255个字符',
        'employeeNo.max' => '工号最多255个字符',
        'entryTime.integer' => '入职日期格式不正确',
        'remarks.max' => '备注最多255个字符',
    ];
}
